package com.co.notaweb.bussines;

import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import com.co.notaweb.entities.PersonaGenerica;

/**
 * @author PC
 * @version 1.0
 * @created 13-nov-2011 12:14:24
 */
@Stateless
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public class PersonaGenericaBussines implements IPersonaGenericaBussinesLocal {
	@PersistenceContext(unitName = "notaweb")
	private EntityManager em;

	public PersonaGenericaBussines() {

	}

	public void finalize() throws Throwable {

	}

	/**
	 * 
	 * @param personaGenerica
	 */
	public void create(PersonaGenerica personaGenerica) {
		em.persist(personaGenerica);

	}

	/**
	 * 
	 * @param personaGenerica
	 */
	public void delete(PersonaGenerica personaGenerica) {
		em.remove(em.find(personaGenerica.getClass(), personaGenerica.getId()));
	}

	/**
	 * 
	 * @param personaGenerica
	 */
	public void edit(PersonaGenerica personaGenerica) {
		em.merge(personaGenerica);
	}

	/**
	 * 
	 * @param id
	 */
	public PersonaGenerica find(long id){
		return em.find(PersonaGenerica.class, id);
	}
	

}